<html>

<head>
<meta name=标题 content="">
<meta name=关键词 content="">
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 15 (filtered)">
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:"Courier New";
	panose-1:2 7 3 9 2 2 5 2 4 4;}
@font-face
	{font-family:Times;
	panose-1:0 0 5 0 0 0 0 2 0 0;}
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:DengXian;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:"\@DengXian";}
@font-face
	{font-family:"Microsoft YaHei";
	panose-1:2 11 5 3 2 2 4 2 2 4;}
@font-face
	{font-family:Menlo;
	panose-1:2 11 6 9 3 8 4 2 2 4;}
@font-face
	{font-family:"\@Microsoft YaHei";}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:12.0pt;
	font-family:DengXian;}
code
	{font-family:Courier;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	text-indent:21.0pt;
	font-size:12.0pt;
	font-family:DengXian;}
p.a, li.a, div.a
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	line-height:200%;
	font-size:12.0pt;
	font-family:"Microsoft YaHei";}
.MsoChpDefault
	{font-family:DengXian;}
 /* Page Definitions */
@page WordSection1
	{size:595.0pt 842.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	layout-grid:15.6pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body lang=ZH-CN style='text-justify-trim:punctuation'>

<div class=WordSection1 style='layout-grid:15.6pt'>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-size:14.0pt;line-height:200%;font-family:"Microsoft YaHei"'>bc</span></b></p>

<p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;
text-indent:21.0pt;line-height:200%;text-autospace:none'><span lang=EN-US
style='font-family:"Microsoft YaHei";color:black;vertical-align:sub'>bc</span><span
style='font-family:"Microsoft YaHei";color:black;vertical-align:sub'>是一种算数语言，其语法和<span
lang=EN-US>c</span>语言类似，可以交互执行。</span><span style='font-family:"Microsoft YaHei"'>通过命令行选项可以获得一个标准的数学库。如果请求，在处理任何文件之前定义数学库。<span
lang=EN-US>BC</span>从处理所有文件的代码开始。命令行中列出的文件按所列顺序排列。在处理完所有文件后，<span lang=EN-US>BC</span>从标准输入中读取。所有代码都在读取时执行。<span
lang=EN-US>(</span>如果文件包含停止处理器的命令，<span lang=EN-US>BC</span>将永远不会从标准输入中读取。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei";color:black;vertical-align:sub'>此命令的适用范围：<span
lang=EN-US>RedHat</span>、<span lang=EN-US>RHEL</span>、<span lang=EN-US>Ubuntu</span>、<span
lang=EN-US>CentOS</span>、<span lang=EN-US>SUSE</span>、<span lang=EN-US>openSUSE</span>、<span
lang=EN-US>Fedora</span>。</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>1</span></b><b><span style='font-family:
"Microsoft YaHei"'>、语法</span></b></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>     bc  [ -hlwsqv ]  [long-options]  [ 
file ... ] </span></b></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>           </span></b></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>2</span></b><b><span style='font-family:
"Microsoft YaHei"'>、选项列表</span></b></p>

<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse;border:none'>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>选项</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border:solid windowtext 1.0pt;
  border-left:none;background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>说明</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-h | --help</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>帮助信息</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-v | --version</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>显示命令版本信息</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-l | --mathlib</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>定义标准数学库
  </span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-i | --interactive</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>强制交互</span></p>
  </td>
 </tr>
 <tr style='height:21.15pt'>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:21.15pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-w | --warn</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt;height:21.15pt'>
  <p class=MsoNormal><span style='font-family:"Microsoft YaHei";color:black'>显示<span
  lang=EN-US>POSIX</span>的警告信息</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-s | --standard</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>使用<span
  lang=EN-US>POSIX</span>标准来处理</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.58%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-q | --quiet</span></p>
  </td>
  <td width="71%" valign=top style='width:71.42%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>不显示欢迎信息</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>&nbsp;</span></b></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>3</span></b><b><span style='font-family:
"Microsoft YaHei"'>、说明</span></b></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>1</span><span
style='font-family:"Microsoft YaHei"'>）数据</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>bc</span><span
style='font-family:"Microsoft YaHei"'>中最基本的元素是数字。数字是任意精度的数字。这种精度既包括整数部分，也包括分数部分。所有的数字在内部用十进制表示，所有的计算都用十进制来表示。<span
lang=EN-US>(</span>此版本截断除法和乘运算的结果。<span lang=EN-US>)</span>数字有两个属性：长度和小数位。长度是数字中有效位的总数，小数位是小数点之后的的有效位数。例如，<span
lang=EN-US>0.000001</span>的长度是<span lang=EN-US>6</span>，小数位是<span lang=EN-US>6</span>；<span
lang=EN-US>1935.000</span>的长度是<span lang=EN-US>7</span>，小数位是<span lang=EN-US>3</span>。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>2</span><span
style='font-family:"Microsoft YaHei"'>）变量</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>数字存储在两种类型的变量中，简单变量和数组。变量名称以字母开头，后面跟着任意数量的字母、数字和下划线。所有字母都必须小写。<span
lang=EN-US>(</span>全字母<span lang=EN-US>-</span>数字名是扩展名。在<span lang=EN-US>POSIX bc</span>中，所有名称都是一个小写字母。<span
lang=EN-US>)</span>变量的类型在上下文中是明确的，因为所有数组变量名称后面都会有方括号<span lang=EN-US>([])</span>。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>有四个特殊的变量：<span lang=EN-US>scale</span>、<span
lang=EN-US>ibase</span>、<span lang=EN-US>obase</span>和<span lang=EN-US>last</span>。<span
lang=EN-US>scale</span>定义了一些操作在小数点之后是如何使用数字的，默认值是<span lang=EN-US>0</span>。<span
lang=EN-US>ibase</span>和<span lang=EN-US>obase</span>定义输入和输出数字的转换基。默认值都是基数<span
lang=EN-US>10</span>。<span lang=EN-US>last(</span>扩展<span lang=EN-US>)</span>是一个变量。它是最后打印的数字的值。所有这些变量可能都有分配给它们的值，以及表达式中使用的值。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>3</span><span
style='font-family:"Microsoft YaHei"'>）注释</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>bc</span><span
style='font-family:"Microsoft YaHei"'>中的注释以字符“<span lang=EN-US>/*</span>”开头，以字符“<span
lang=EN-US>*/</span>”结尾。注释可以从任何地方开始，并显示为输入中的单个空格。<span lang=EN-US>(</span>这会导致注释分隔其他输入项。例如，在变量名的中间找不到注释。<span
lang=EN-US>)</span>注释包括注释开始和结束之间的任何新行<span lang=EN-US>(</span>行尾<span
lang=EN-US>)</span>。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>为了支持<span lang=EN-US>bc</span>脚本的使用，添加了行注释作为扩展。行注释从“<span
lang=EN-US>#</span>”字符开始，继续到行的结束。行结束字符不是注释的一部分，而是正常处理的。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>如果命令行上的任何文件无法打开，<span lang=EN-US>bc</span>将报告该文件不可用并终止。</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>4</span></b><b><span style='font-family:
"Microsoft YaHei"'>、关于表达式</span></b></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>这些数字由表达式和语句操作。由于语言设计为交互式，所以语句和表达式会尽快执行。没有<span
lang=EN-US>“</span>主<span lang=EN-US>”</span>程序，而是在遇到时执行代码。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>一个简单的表达式只是一个常量。<span lang=EN-US>BC</span>使用变量<span
lang=EN-US>ibase</span>指定的当前输入基将常量转换为内部十进制数。<span lang=EN-US>(</span>函数中有一个例外。<span
lang=EN-US>)ibase</span>的有效值为<span lang=EN-US>2</span>到<span lang=EN-US>16</span>，将超出此范围之后，分配给<span
lang=EN-US>ibase</span>的值可能是<span lang=EN-US>2</span>或<span lang=EN-US>16</span>。输入数字可能包含字符<span
lang=EN-US>0-9</span>和<span lang=EN-US>A-F</span>。<span lang=EN-US>(</span>注：它们必须是大写字母，小写字母是变量名称。<span
lang=EN-US>)</span>无论<span lang=EN-US>ibase</span>的值是多少，单数数字总是有该数字的值。<span
lang=EN-US>(</span>即<span lang=EN-US>A=10</span>。<span lang=EN-US>)</span>对于多位数字，<span
lang=EN-US>bc</span>将所有大于或等于<span lang=EN-US>ibase</span>的输入数字更改为<span
lang=EN-US>IBASE-1</span>的值。这使得<span lang=EN-US>FFF</span>始终输入的最大<span
lang=EN-US>3</span>位数。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>完全表达式类似于许多其他高级语言。由于只有一种数字，所以没有混合类型的规则。相反，有关于表达式精度的规则。每个表达式都有一个精度。这是从原始数字的精度、所执行的操作以及在许多情况下变量<span
lang=EN-US>scale</span>的值导出的。变量<span lang=EN-US>scale</span>的有效值为<span
lang=EN-US>0</span>到可由<span lang=EN-US>c</span>语言整数表达的最大值。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>在以下合法表达式的描述中，<span lang=EN-US>“expr”</span>指的是一个完整的表达式，<span
lang=EN-US>“var”</span>指的是一个简单的或数组变量。除非特别提到，结果的精度是所涉及的表达式的最大精度。</span></p>

<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse;border:none'>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>普通表达式</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border:solid windowtext 1.0pt;
  border-left:none;background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>说明</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>-expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal><span style='font-family:"Microsoft YaHei"'>结果是对表达式的否定。</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>++var</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>变量增加<span
  lang=EN-US>1</span>，而新值是表达式的结果</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>--var</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>变量减<span
  lang=EN-US>1</span>，而新值是表达式的结果</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>var++</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是变量的值，然后变量增加<span
  lang=EN-US>1</span></span></p>
  </td>
 </tr>
 <tr style='height:21.15pt'>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:21.15pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>var--</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt;height:21.15pt'>
  <p class=MsoNormal><span style='font-family:"Microsoft YaHei";color:black'>表达式的结果是变量的值，然后变量减<span
  lang=EN-US>1</span></span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr * expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是这两个表达式的乘积</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr + expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是这两个表达式的和</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr – expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是这两个表达式的差</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr / expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是这两个表达式的商。结果的精度是变量<span
  lang=EN-US>scale</span>的值。</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr % expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是<span
  lang=EN-US>“</span>余数<span lang=EN-US>”</span></span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr ^ expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>表达式的结果是<span
  lang=EN-US>n</span>次方，第二个表达式必须是整数。如果指数是负数，那么结果的精度是<span lang=EN-US>scale</span></span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>（<span
  lang=EN-US>expr</span>）</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>强制对表达式进行计算</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>var = expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>变量就是表达式的值</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>var &lt;op&gt;= expr</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>相当于“<span
  lang=EN-US>var=var&lt;op&gt;expr</span>”，例如<span lang=EN-US>”var -= expr” </span>等价于“<span
  lang=EN-US>var=var-expr</span>”</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span></p>

<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse;border:none'>
 <tr>
  <td width=208 valign=top style='width:208.3pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>关系表达式</span></p>
  </td>
  <td width=625 colspan=3 valign=top style='width:625.25pt;border:solid windowtext 1.0pt;
  border-left:none;background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>关系表达式是一种特殊的表达式，计算结果总是<span
  lang=EN-US>0</span>或<span lang=EN-US>1</span>。如果关系为真，则计算为<span lang=EN-US>1</span>；如果关系为假，则结果是<span
  lang=EN-US>0.</span>。这些表达式可能出现在任何合法表达式中。<span lang=EN-US>(POSIX bc</span>要求关系表达式仅用于<span
  lang=EN-US>if</span>、<span lang=EN-US>while</span>和语句，并且只能在其中进行一次关系测试。<span
  lang=EN-US>)</span></span></p>
  </td>
 </tr>
 <tr>
  <td width=208 valign=top style='width:208.3pt;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 &lt; expr2</span></p>
  </td>
  <td width=208 valign=top style='width:208.35pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 &lt;= expr2</span></p>
  </td>
  <td width=208 valign=top style='width:208.45pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 &gt; expr2</span></p>
  </td>
  <td width=208 valign=top style='width:208.45pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 &gt;= expr2</span></p>
  </td>
 </tr>
 <tr>
  <td width=208 valign=top style='width:208.3pt;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 == expr2</span></p>
  </td>
  <td width=208 valign=top style='width:208.35pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 != expr2</span></p>
  </td>
  <td width=208 valign=top style='width:208.45pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 &amp;&amp; expr2</span></p>
  </td>
  <td width=208 valign=top style='width:208.45pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>expr1 || expr2</span></p>
  </td>
 </tr>
 <tr>
  <td width=208 valign=top style='width:208.3pt;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>!expr</span></p>
  </td>
  <td width=208 valign=top style='width:208.35pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>&nbsp;</span></p>
  </td>
  <td width=208 valign=top style='width:208.45pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>&nbsp;</span></p>
  </td>
  <td width=208 valign=top style='width:208.45pt;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>&nbsp;</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>运算符的优先级如下，从上到下依次增加：</span></p>

<table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse;border:none'>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>运算符</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border:solid windowtext 1.0pt;
  border-left:none;background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>结合方式</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>||</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal><span style='font-family:"Microsoft YaHei"'>左结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>&amp;&amp;</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>左结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>！</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>不结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>关系运算符</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>左结合</span></p>
  </td>
 </tr>
 <tr style='height:21.15pt'>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt;height:21.15pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>赋值运算符</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt;height:21.15pt'>
  <p class=MsoNormal>右结合</p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>+</span><span style='font-family:"Microsoft YaHei"'>和<span
  lang=EN-US>-</span></span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>左结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>*</span><span style='font-family:"Microsoft YaHei"'>、<span
  lang=EN-US>/</span>、<span lang=EN-US>%</span></span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>左结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>^</span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>右结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>一元运算符<span
  lang=EN-US> -</span></span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>不结合</span></p>
  </td>
 </tr>
 <tr>
  <td width="28%" valign=top style='width:28.4%;border:solid windowtext 1.0pt;
  border-top:none;padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>++</span><span style='font-family:"Microsoft YaHei"'>和<span
  lang=EN-US>--</span></span></p>
  </td>
  <td width="71%" valign=top style='width:71.6%;border-top:none;border-left:
  none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt'>
  <p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>不结合</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>选择此优先级是为了使符合<span lang=EN-US>POSIX</span>的<span
lang=EN-US>bc</span>程序能够正确运行。这将导致关系运算符和逻辑运算符在与赋值表达式一起使用时有一些不寻常的行为。例如下面的表达式：</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>a = 3&lt;5</span></p>

<p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>大多数<span
lang=EN-US>C</span>程序员会假设这会将<span lang=EN-US>“3&lt;5”(</span>值<span lang=EN-US>1)</span>的结果赋给变量<span
lang=EN-US>“a”</span>，这在<span lang=EN-US>bc</span>中所做的是将值<span lang=EN-US>3</span>赋给变量<span
lang=EN-US>“a”</span>，然后比较<span lang=EN-US>3</span>到<span lang=EN-US>5</span>。在使用关系运算符和逻辑运算符与赋值运算符时，最好使用括号。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>在<span lang=EN-US>bc</span>中还提供了一些特殊的表达式。这些表达式与用户定义的函数和标准函数有关。它们都以<span
lang=EN-US>“</span>名称<span lang=EN-US>(</span>参数<span lang=EN-US>)”</span>的形式出现。有几个标准函数：</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>1</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>length</span>（<span
lang=EN-US>expr</span>），计算表达式结果的有效位数。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>2</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>read</span>（），<span
lang=EN-US>Read</span>函数<span lang=EN-US>(</span>一个扩展<span lang=EN-US>)</span>将从标准输入中读取一个数字，而不管该函数发生在何处。注意，这可能会导致标准输入中的数据和程序混合出现问题。这个函数的最佳使用是在一个已经编写好的程序中，这个程序需要用户输入，但绝不允许从用户输入程序代码。读函数的值是从标准输入中读取的数字，使用转换基的变量<span
lang=EN-US>ibase</span>的当前值。</span></p>

<p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>·<span
lang=EN-US>     3</span>）<span lang=EN-US>scale ( expr )</span>，这个函数的值是<span
lang=EN-US>expr</span>表达式中小数点之后的位数。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>4</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>sqrt ( expression )</span>，函数的结果是表达式的开方值。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>5</span></b><b><span style='font-family:
"Microsoft YaHei"'>、关于语句</span></b></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>语句<span
lang=EN-US>(</span>在大多数代数语言中<span lang=EN-US>)</span>提供表达式计算的顺序。在<span
lang=EN-US>bc</span>中，语句被<span lang=EN-US>“</span>尽快<span lang=EN-US>”</span>执行。执行发生在遇到的换行符的时候，并且有一个或多个完整的语句。由于这种立即执行，换行符在<span
lang=EN-US>bc</span>中非常重要。事实上，分号和换行符都用作语句分隔符。如果换行符放置不当，将导致语法错误。因为换行符是语句分隔符，所以可以使用反斜杠字符隐藏换行符。<span
lang=EN-US>(&lt;nl&gt;)</span>在<span lang=EN-US>bc</span>中显示为空格而不是新行。语句列表是由分号和换行符分隔的一系列语句。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     1</span><span style='font-family:"Microsoft YaHei"'>）表达式</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>这条语句做两件事之一。如果表达式以<span
lang=EN-US>“&lt;</span>变量<span lang=EN-US>&gt;&lt;</span>赋值<span lang=EN-US>&gt;.”</span>开头，则被认为是赋值语句。如果表达式不是赋值语句，则计算表达式并将表达式打印到输出。在打印数字之后，将打印换行符。例如，<span
lang=EN-US>“a=1”</span>是一个赋值语句和<span lang=EN-US>“(a=1)”</span>是一个具有内嵌赋值的表达式。输出基<span
lang=EN-US>obase</span>的有效值是<span lang=EN-US>2~</span></span><span lang=EN-US> </span><span
lang=EN-US style='font-family:"Microsoft YaHei"'>BC_BASE_MAX</span><span
style='font-family:"Microsoft YaHei"'>。对于基数<span lang=EN-US>2</span>至<span
lang=EN-US>16</span>，通常采用书写数字的方法。对于大于<span lang=EN-US>16</span>的基数，<span
lang=EN-US>bc</span>使用多字符数字方法将每个较高的基数打印成以<span lang=EN-US>10</span>为基数的数据。由于数字具有任意精度，一些数字可能无法在一条输出线上打印。这些长数字将被分割，以<span
lang=EN-US>“\”</span>作为一行上的最后一个字符，每行打印的最大字符数为<span lang=EN-US>70</span>个。由于<span
lang=EN-US>bc</span>的交互性，打印一个数字会导致最后将打印值赋值给特殊变量“<span lang=EN-US>last</span>”的副作用。这允许用户恢复打印的最后一个值，而不必重新键入打印数字的表达式。将<span
lang=EN-US>last</span>变量赋值为<span lang=EN-US>“</span>最后一个值<span lang=EN-US>”</span>是合法的，并将最后一个打印的值用指定的值覆盖。新赋值将保持不变，直到打印下一个数字或将另一个值分配给“<span
lang=EN-US>last</span>”为止。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     2</span><span style='font-family:"Microsoft YaHei"'>）字符串</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>字符串被打印到输出。字符串以双引号开始，包含所有字符直到下一个双引号字符。所有字符都是字面意思，包括任何换行符。字符串后不打印换行符。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     3</span><span style='font-family:"Microsoft YaHei"'>）打印列表</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>print</span><span
style='font-family:"Microsoft YaHei"'>语句<span lang=EN-US>(</span>扩展<span
lang=EN-US>)</span>提供了另一种输出方法。<span lang=EN-US>“list”</span>是由逗号分隔的字符串和表达式的列表。每个字符串或表达式都按列表的顺序打印。不打印终止换行符。表达式的将被计算出值，最后将其值打印并分配给变量“<span
lang=EN-US>last</span>”。打印语句中的字符串将打印到输出中，并可能包含特殊字符。特殊字符以反斜杠字符<span lang=EN-US>“\”</span>开始。<span
lang=EN-US>bc</span>识别的特殊字符是<span lang=EN-US>“a”(</span>警报或钟<span lang=EN-US>)</span>、<span
lang=EN-US>“b”(</span>反斜杠<span lang=EN-US>)</span>、<span lang=EN-US>“f”(</span>表单提要<span
lang=EN-US>)</span>、<span lang=EN-US>“n”(</span>换行符<span lang=EN-US>)</span>、<span
lang=EN-US>“r”(</span>回车<span lang=EN-US>)</span>、<span lang=EN-US>“q”(</span>双引号<span
lang=EN-US>)</span>、<span lang=EN-US>“t”(</span>制表符<span lang=EN-US>)</span>和<span
lang=EN-US>“\”(</span>反斜杠<span lang=EN-US>)</span>。反斜杠后面的任何其他字符都将被忽略。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     4</span><span style='font-family:"Microsoft YaHei"'>）语句列表</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>这是复合语句。它允许将多个语句组合在一起执行。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     5</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>if (</span>表达式<span lang=EN-US>)  statement 1  [else statement 2]</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     if</span><span style='font-family:"Microsoft YaHei"'>语句根据表达式的值决定执行<span
lang=EN-US>statement 1</span>或<span lang=EN-US>statement 2</span>。如果表达式为非零，则执行<span
lang=EN-US>statement 1</span>。如果存在<span lang=EN-US>statement 2</span>，且表达式的值为<span
lang=EN-US>0</span>的时候执行<span lang=EN-US>statement 2</span>。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>6</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>while ( expression )  statement</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     while</span><span style='font-family:"Microsoft YaHei"'>语句将在表达式为非零时执行语句。它在每次执行语句之前计算表达式。循环的终止是由零表达式值或<span
lang=EN-US>break</span>语句的执行引起的。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     7</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>for ( [expression1] ; [expression2] ; [expression3] )  statement</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     for</span><span style='font-family:"Microsoft YaHei"'>语句控制语句的重复执行。表达式<span
lang=EN-US>1</span>是在循环之前计算的。表达式<span lang=EN-US>2</span>是在每次语句执行之前计算的。如果表达式<span
lang=EN-US>2</span>为非零，则计算语句；如果为零，则终止循环。每次执行语句后，计算表达式<span lang=EN-US>3</span>。在重新计算表达式<span
lang=EN-US>2</span>之前，如果未找到表达式<span lang=EN-US>1</span>或表达式<span lang=EN-US>3</span>，则不会在计算值的点上对其进行任何计算。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     8</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>break</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     break</span><span style='font-family:"Microsoft YaHei"'>语句用来强制退出，通常用在<span
lang=EN-US>for</span>语句或者<span lang=EN-US>while</span>语句中。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     9</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>continue</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     continue</span><span style='font-family:"Microsoft YaHei"'>语句用来结束本次循环。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     10</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>halt</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     halt</span><span style='font-family:"Microsoft YaHei"'>语句会导致<span
lang=EN-US>bc</span>程序退出。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     11</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>return</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>函数返回<span
lang=EN-US>0.</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     12</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>return expr</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>返回表达式的值。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     13</span><span style='font-family:"Microsoft YaHei"'>）伪语句，这些语句不会执行，他们在编译的时候才会起作用。下面列出伪语句</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>           a</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>limits</span>，打印由于<span lang=EN-US>bc</span>版本而产生的限制</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>           b</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>quit</span>，遇到<span lang=EN-US>quit</span>指令的时候就会退出<span lang=EN-US>bc</span>，无论它出现在什么地方。例如“<span
lang=EN-US>if (0 == 1) quit</span>”就会导致退出<span lang=EN-US>bc</span></span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>           c</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>warranty</span>，打印较长的授权通知</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>6</span></b><b><span style='font-family:
"Microsoft YaHei"'>、函数</span></b></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>     </span></b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>1</span><span style='font-family:"Microsoft YaHei"'>）函数</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>     </span></b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>bc</span><span style='font-family:"Microsoft YaHei"'>中的函数总是计算一个值并将其返回给调用者。函数定义是<span
lang=EN-US>“</span>动态的<span lang=EN-US>”</span>，在输入中遇到定义之前，函数是未定义的。然后使用该定义，直到遇到相同名称的另一个定义函数。然后，新定义取代旧的定义。函数定义方式如下：</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>           define name ( parameters ) { newline</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>            auto_list   statement_list }</span></p>

<p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>函数的调用很简单“<span
lang=EN-US>name</span>（<span lang=EN-US>parameters</span>）”。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     2</span><span style='font-family:"Microsoft YaHei"'>）参数</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>参数是数字或数组。在函数定义中，可以有<span
lang=EN-US>0</span>个或者多个参数，通过逗号分隔开。所有参数都是通过值参数调用的。数组是通过符号<span lang=EN-US>“name[]</span>在参数定义中指定的。在函数调用中，实参是数字参数的完整表达式。相同的符号。数组的定义和传值使用相同的符号。命名数组通过值传递给函数。由于函数定义是动态的，因此在调用函数时会检查参数号和类型。参数数量或类型的不匹配都会导致运行时错误。对未定义函数的调用也会出现运行时错误。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     3</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>auto_list</span></span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>“<span lang=EN-US>auto_list</span>”是供<span
lang=EN-US>“</span>本地<span lang=EN-US>”</span>使用的变量的可选列表。<span lang=EN-US>auto_list</span>的语法<span
lang=EN-US>(</span>如果存在<span lang=EN-US>)</span>是<span lang=EN-US>“autoname</span>，<span
lang=EN-US>…</span>；<span lang=EN-US>”</span>。<span lang=EN-US>(</span>分号是可选的。<span
lang=EN-US>)</span>每个名称都是自动变量的名称。数组可以使用与参数相同的表示法来指定。这些变量的值在函数开始时被推入堆栈中。然后将变量初始化为零，并在函数的整个执行过程中使用。在函数退出时，这些变量被弹出，以便恢复这些变量的原始值<span
lang=EN-US>(</span>在函数调用时<span lang=EN-US>)</span>。这些参数实际上是自动变量，它们被初始化为函数调用中提供的值。自动变量不同于传统局部变量，因为如果函数<span
lang=EN-US>A</span>调用函数<span lang=EN-US>B</span>，<span lang=EN-US>B</span>可以使用相同的名称访问函数<span
lang=EN-US>A</span>的自动变量，除非函数<span lang=EN-US>B</span>调用它们为自动变量。由于自动变量和参数被推到堆栈上，<span
lang=EN-US>bc</span>支持递归函数。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     4</span><span style='font-family:"Microsoft YaHei"'>）函数体</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>函数体是一系列<span lang=EN-US>bc</span>语句的列表。同样，语句用分号或换行符分隔。返回语句导致函数的终止和值的返回。返回语句有两个版本。第一个形式<span
lang=EN-US>“return”</span>将值<span lang=EN-US>0</span>返回给调用表达式。第二种形式<span
lang=EN-US>“return (</span>表达式<span lang=EN-US>)”</span>计算表达式的值并将该值返回给调用表达式。在每个函数的末尾有一个隐含的<span
lang=EN-US>“return (0)”</span>。这允许一个函数终止并返回<span lang=EN-US>0</span>，而不需要显式返回语句。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>函数还会改变变量<span lang=EN-US>ibase</span>的用法。函数体中的所有常量都将在函数调用时使用<span
lang=EN-US>ibase</span>的值进行转换。在函数执行过程中，<span lang=EN-US>ibase</span>的更改将被忽略，但标准函数读取除外，后者将始终使用<span
lang=EN-US>ibase</span>的当前值来转换数字。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>当前版本的<span
lang=EN-US>bc</span>，在函数中添加了几个扩展。首先，定义的格式稍微放松了一些。标准要求开始大括号与定义关键字在同一行，所有其他部分必须在下面的行上。这个版本的<span
lang=EN-US>bc</span>将允许之前的任何数目的换行符。在函数的开头支撑之后，例如，下面的定义是合法的：</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>           define  d  (n)  { return  (2*n); }</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>       define  d  (n)</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>            { return  (2*n); }</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     5</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>void</span>类型</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>函数可以定义为<span lang=EN-US>void</span>。空函数不返回值，因此可能不会在任何需要值的地方使用。空函数在输入行调用时不会产生任何输出。关键字<span
lang=EN-US>void</span>放在关键字定义和函数名称之间。例如，请考虑下面的例子</span></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>define  py (y)  {
print &quot;---&gt;&quot;, y, &quot;&lt;---&quot;, &quot;0; }</span></b></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>define  void  px
(x)  { print &quot;---&gt;&quot;, x, &quot;&lt;---&quot;, &quot;0; }</span></b></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>py(1)</span></b></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>---&gt;1&lt;---</span></b></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>0                   
//</span></b><b><span style='font-family:"Microsoft YaHei"'>由于<span lang=EN-US>py</span>不是<span
lang=EN-US>void</span>，因此有默认返回值，因此这里打印了它的返回值，</span></b></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>px(1)</span></b></p>

<p class=MsoNormal style='margin-left:21.0pt;text-indent:21.0pt;line-height:
200%'><b><span lang=EN-US style='font-family:"Microsoft YaHei"'>---&gt;1&lt;---           
//px</span></b><b><span style='font-family:"Microsoft YaHei"'>是<span
lang=EN-US>void</span>类型，最后不会打印返回值</span></b></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>此外，还为数组添加了按变量调用。为了申明一个数组变量，函数中的数组参数是这样定义的<span
lang=EN-US>“*name[]” </span>。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>7</span></b><b><span style='font-family:
"Microsoft YaHei"'>、数学库</span></b></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     1</span><span style='font-family:"Microsoft YaHei"'>）如果使用“<span
lang=EN-US>-l</span>”选项调用<span lang=EN-US>bc</span>，则预加载一个数学库，并将默认精度设置为<span
lang=EN-US>20</span>。数学库中有一下的函数：</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>s</span><span
style='font-family:"Microsoft YaHei"'>（<span lang=EN-US>x</span>），计算<span
lang=EN-US>x</span>的正弦值，<span lang=EN-US>x</span>是弧度值。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>c</span><span
style='font-family:"Microsoft YaHei"'>（<span lang=EN-US>x</span>），计算<span
lang=EN-US>x</span>的余弦值，<span lang=EN-US>x</span>是弧度值。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     a</span><span style='font-family:"Microsoft YaHei"'>（<span
lang=EN-US>x</span>），计算<span lang=EN-US>x</span>的反正切值，返回弧度。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     l</span><span style='font-family:"Microsoft YaHei"'>（<span
lang=EN-US>x</span>），计算<span lang=EN-US>x</span>的自然对数。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     e</span><span style='font-family:"Microsoft YaHei"'>（<span
lang=EN-US>x</span>），<span lang=EN-US>e</span>的<span lang=EN-US>x</span>次方。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     j</span><span style='font-family:"Microsoft YaHei"'>（<span
lang=EN-US>n</span>，<span lang=EN-US>x</span>），从<span lang=EN-US>n</span>到<span
lang=EN-US>x</span>的阶数。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     2</span><span style='font-family:"Microsoft YaHei"'>）例子</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>下面的句子可以将“<span
lang=EN-US>pi</span>”的值赋值给<span lang=EN-US>shell</span>变量<span lang=EN-US>pi</span></span></p>

<table class=a0 border=1 cellspacing=0 cellpadding=0 width="92%"
 style='width:92.0%;margin-left:48.2pt;border-collapse:collapse;border:none'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>pi = $(echo  &quot;scale=10;
  4*a(1)&quot;  |  bc  -l)</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>下面的句子就是数学库中<span lang=EN-US>e</span>的次方定义方式</span></p>

<table class=a0 border=1 cellspacing=0 cellpadding=0 width="92%"
 style='width:92.0%;margin-left:48.2pt;border-collapse:collapse;border:none'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>scale = 20</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>/* Uses the fact that e^x =
  (e^(x/2))^2</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    When x is small enough,
  we use the series:</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    e^x = 1 + x + x^2/2! +
  x^3/3! + ...</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>*/</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>define e(x) {</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    auto  a, d, e, f, i, m,
  v, z</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>&nbsp;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    /* Check the sign of x.
  */</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    if (x&lt;0) {</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        m = 1</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        x = -x</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    }</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>&nbsp;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    /* Precondition x. */</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    z = scale;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    scale = 4 + z + .44*x;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    while (x &gt; 1) {</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        f += 1;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        x /= 2;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    }</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>&nbsp;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    /* Initialize the
  variables. */</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    v = 1+x</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    a = x</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    d = 1</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    for (i=2; 1; i++) {</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        e = (a *= x) / (d *=
  i)</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        if (e == 0) {</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>            if (f&gt;0)
  while (f--)  v = v*v;</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>            scale = z</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>            if (m) return
  (1/v);</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        return (v/1);</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        }</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>        v += e</span></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><span
  lang=EN-US style='font-family:"Microsoft YaHei"'>    }</span></p>
  <p class=MsoNormal style='line-height:200%'><span lang=EN-US
  style='font-family:"Microsoft YaHei"'>}</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>下面的语句实现一个计算支票簿余额的简单程序</span></p>

<table class=a0 border=1 cellspacing=0 cellpadding=0 width="92%"
 style='width:92.0%;margin-left:48.2pt;border-collapse:collapse;border:none'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>scale=2</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>print
  &quot;\nCheck book program!\n&quot;</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>print
  &quot;  Remember, deposits are negative transactions.\n&quot;</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>print
  &quot;  Exit by a 0 transaction.\n\n&quot;</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>&nbsp;</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>print
  &quot;Initial balance? &quot;; bal = read()</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>bal /=
  1</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>print
  &quot;\n&quot;</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>while
  (1) {</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    &quot;current
  balance = &quot;; bal</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    &quot;transaction?
  &quot;; trans = read()</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    if
  (trans == 0) break;</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    bal
  -= trans</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    bal
  /= 1</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>}</span></code></p>
  <p class=MsoNormal align=left style='text-align:left;line-height:200%'><code><span
  lang=EN-US style='font-size:10.0pt;line-height:200%;font-family:Menlo'>quit</span></code></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>下面的语句采用递归的方式计算<span
lang=EN-US>x</span>的阶乘</span></p>

<table class=a0 border=1 cellspacing=0 cellpadding=0 width="92%"
 style='width:92.0%;margin-left:48.2pt;border-collapse:collapse;border:none'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>define f (x) {</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    if (x &lt;=
  1) return (1);</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>    return
  (f(x-1) * x);</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>}</span></code></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>8</span></b><b><span style='font-family:
"Microsoft YaHei"'>、<span lang=EN-US>readline</span>和<span lang=EN-US>libedit</span>选项</span></b></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>可以编译<span
lang=EN-US>GNU bc(</span>通过一个配置选项<span lang=EN-US>)</span>来使用<span lang=EN-US>GNU
readline</span>输入编辑器库或<span lang=EN-US>bsd libedit</span>库。这允许用户在将行发送到<span
lang=EN-US>bc</span>之前进行编辑。它还允许保存以前键入的行的历史记录。当选择此选项时，<span lang=EN-US>bc</span>还有一个特殊变量。变量“<span
lang=EN-US>history</span>”是保留的历史记录行数。对于<span lang=EN-US>readline</span>，值<span
lang=EN-US>-1</span>表示不限制历史记录的行数，<span lang=EN-US>0</span>将禁用历史记录功能，默认值为<span
lang=EN-US>100</span>。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>9</span></b><b><span style='font-family:
"Microsoft YaHei"'>、差别</span></b></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
style='font-family:"Microsoft YaHei"'>这个版本的<span lang=EN-US>bc</span>是从<span
lang=EN-US>POSIX P 1003.2/D11</span>草案中实现的，包含了与草案和传统实现相比的一些区别和扩展，它不是以传统的方式使<span
lang=EN-US>bc(1)</span>实现的，这个版本是一个解析和运行程序字节代码转换的单一进程。这里有一个<span lang=EN-US>“</span>无文档<span
lang=EN-US>”</span>选项<span lang=EN-US>(-c)</span>，它导致程序将字节码输出到标准输出，而不是运行它。它主要用于调试解析器和准备数学库。差异的一个主要来源是扩展，下面列出一些差异和扩展：</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     1</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>LANG</span>环境变量，此版本在处理<span lang=EN-US>lang</span>环境变量和从<span
lang=EN-US>lc_</span>开始的所有环境变量时不符合<span lang=EN-US>POSIX</span>标准。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     2</span><span style='font-family:"Microsoft YaHei"'>）名字，传统和<span
lang=EN-US>POSIX bc</span>都有用于函数、变量和数组的单字母名称。它们被扩展为以字母开头的多字符名称，可以包含字母、数字和下划线字符。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     3</span><span style='font-family:"Microsoft YaHei"'>）字符串，字符串不允许包含<span
lang=EN-US>NUL</span>字符。<span lang=EN-US>POSIX</span>表示所有字符都必须包含在字符串中。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     4</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>last</span>，<span lang=EN-US>POSIX bc</span>中没有<span lang=EN-US>last</span>变量。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     5</span><span style='font-family:"Microsoft YaHei"'>）比较，<span
lang=EN-US>POSIX bc</span>只允许在<span lang=EN-US>if</span>语句、<span lang=EN-US>while</span>语句和<span
lang=EN-US>for</span>语句的第二个表达式中进行比较。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     6</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>if</span>语句，<span lang=EN-US>POSIX bc</span>中<span lang=EN-US>if</span>语句没有<span
lang=EN-US>else</span>。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     7</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>for</span>语句，<span lang=EN-US>POIX bc</span>中要求<span lang=EN-US>for</span>语句中的<span
lang=EN-US>3</span>个表达式都必须具备。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     8</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>&amp;&amp;</span>，<span lang=EN-US>||</span>，！，<span lang=EN-US>POSIX
bc</span>中没有逻辑运算。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     9</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>read</span>，<span lang=EN-US>POSIX bc</span>没有<span lang=EN-US>read</span>功能。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     10</span><span style='font-family:"Microsoft YaHei"'>）打印语句，<span
lang=EN-US>POSIX bc</span>没有打印语句。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     11</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>continue</span>语句，<span lang=EN-US>POSIX bc</span>没有<span
lang=EN-US>continue</span>语句。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     12</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>return</span>，<span lang=EN-US>POSIX bc</span>要求<span lang=EN-US>return</span>的表达式加括号。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     13</span><span style='font-family:"Microsoft YaHei"'>）数组参数，<span
lang=EN-US>POSIX bc</span>不<span lang=EN-US>(</span>目前<span lang=EN-US>)</span>完全支持数组参数。<span
lang=EN-US>POSIX</span>语法允许函数定义中的数组，但没有提供将数组指定为实际参数的方法。<span lang=EN-US>(</span>这很可能是语法上的疏忽。<span
lang=EN-US>)</span>传统的<span lang=EN-US>bc</span>实现只通过值数组参数进行调用。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     14</span><span style='font-family:"Microsoft YaHei"'>）函数，<span
lang=EN-US>POSIX bc</span>要求函数开头的大括号和<span lang=EN-US>define</span>关键字在同一行，语句在下一行。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     15</span><span style='font-family:"Microsoft YaHei"'>）<span
lang=EN-US>=+, =-, =*, =/, =%, =^</span>。<span lang=EN-US>POSIX bc</span>不要求定义这些<span
lang=EN-US>“</span>旧样式<span lang=EN-US>”</span>赋值操作符。此版本可能允许这些<span lang=EN-US>“</span>旧样式<span
lang=EN-US>”</span>赋值。使用限制语句查看安装的版本是否支持它们。如果它确实支持<span lang=EN-US>“</span>旧样式<span
lang=EN-US>”</span>赋值运算符，则<span lang=EN-US>“a=-1”</span>语句将使<span lang=EN-US>a</span>减少<span
lang=EN-US>1</span>，而不是将<span lang=EN-US>a</span>设置为值<span lang=EN-US>-1</span>。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     16</span><span style='font-family:"Microsoft YaHei"'>）数字中的空格，<span
lang=EN-US>bc</span>的其他实现允许数字空格。例如，<span lang=EN-US>“x=1 3”</span>将值<span
lang=EN-US>13</span>赋值给变量<span lang=EN-US>x</span>。相同的语句将导致<span lang=EN-US>bc</span>版本中的语法错误。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     17</span><span style='font-family:"Microsoft YaHei"'>）错误和执行，在程序中发现语法和其他错误时，此实现与其他实现的代码不同。如果在函数定义中发现语法错误，则错误恢复机制将尝试查找语句的开头并继续解析函数。一旦在函数中发现语法错误，该函数将不可调用并变为未定义。交互执行代码中的语法错误将使当前执行块失效。执行块由在完整语句序列之后出现的行尾终止。例如</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     a = 1</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     b = 2</span></p>

<p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>这个语句有两个执行块，而下面的语句</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     {a = 1</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     b = 2}</span></p>

<p class=MsoNormal style='line-height:200%'><span style='font-family:"Microsoft YaHei"'>只有一个执行块。任何运行时错误都会终止当前的执行块，而警告则不会。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     18</span><span style='font-family:"Microsoft YaHei"'>）中断，在交互会话期间，<span
lang=EN-US>SIGINT</span>信号<span lang=EN-US>(</span>通常由终端上的“<span lang=EN-US>ctrl+c</span>“生成<span
lang=EN-US>)</span>将导致当前执行块的执行中断。它将显示一个<span lang=EN-US>“</span>运行时<span
lang=EN-US>”</span>错误，指示哪个功能被中断。在所有运行时结构被清除后，将打印一条消息通知用户<span lang=EN-US>bc</span>准备好接收更多的输入。所有先前定义的函数都保留定义，所有非自动变量的值是中断点的值。在清理过程中，所有自动变量和函数参数都会被移除。对于一个非交互式会话，<span
lang=EN-US>SIGINT</span>信号将终止<span lang=EN-US>bc</span>的整个运行。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>10</span></b><b><span style='font-family:
"Microsoft YaHei"'>、限制</span></b></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>下面列出当前<span
lang=EN-US>bc</span>程序的一些限制，有一些限制可能已经被用户修改过。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>1</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>BC_BASE_MAX</span>，最大输出基设置为<span
lang=EN-US>999</span>。最大输入基为<span lang=EN-US>16</span>。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>2</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>BC_DIM_MAX</span>，这是当前分布的<span
lang=EN-US>65535</span>以内的任意限制，每个机器可能都不一样。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>3</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>BC_SCALE_MAX</span>，小数点前后的位数都由<span
lang=EN-US>INT_MAX</span>限制。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>4</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>BC_STRING_MAX</span>，字符串中的字符字数由<span
lang=EN-US>INT_MAX</span>限制。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>5</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>exponent</span>，指数运算中的指数值由<span
lang=EN-US>LONG_MAX</span>限制。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>6</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>variable names</span>，当前对每个简单变量、数组和函数名字的限制<span
lang=EN-US>32767</span>。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>11</span></b><b><span style='font-family:
"Microsoft YaHei"'>、环境变量</span></b></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     </span><span style='font-family:"Microsoft YaHei"'>下面的环境变量由<span
lang=EN-US>bc</span>程序来控制</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>1</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>POSIXLY_CORRECT</span>，和“<span
lang=EN-US>-s</span>”选项一样。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>2</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>BC_ENV_ARGS</span>，这是另一种获取<span
lang=EN-US>bc</span>参数的机制。格式与命令行参数相同。这些参数是先处理的，因此环境参数中列出的任何文件在任何命令行参数文件之前都会被处理。这允许用户设置<span
lang=EN-US>“</span>标准<span lang=EN-US>”</span>选项和文件，以便在每次调用环境变量中的文件通常包含用户希望在每次运行<span
lang=EN-US>bc</span>时定义的函数定义。</span></p>

<p class=MsoNormal style='text-indent:21.0pt;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>3</span><span
style='font-family:"Microsoft YaHei"'>）<span lang=EN-US>BC_LINE_LENGTH</span>，这应该是一个整数，指定数字输出行中的字符数。这包括用于长数字的反斜杠和换行符。，如果值是<span
lang=EN-US>0</span>，将禁用多行功能。此变量的任何其他值如果小于<span lang=EN-US>3</span>，则将行长设置为<span
lang=EN-US>70</span>。</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><b><span lang=EN-US
style='font-family:"Microsoft YaHei"'>12</span></b><b><span style='font-family:
"Microsoft YaHei"'>、实例</span></b></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     1</span><span style='font-family:"Microsoft YaHei"'>）简单计算</span></p>

<table class=a0 border=1 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse;border:none'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>[root@192 ~]# <b>bc</b></span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>bc 1.06.95  <b>    //</b></span></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>欢迎语句</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>Copyright
  1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>This is free
  software with ABSOLUTELY NO WARRANTY.</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>For details type
  `warranty'. </span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><b><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>12+23    //</span></b></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>输入加法表达式，回车</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><b><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>35       //</span></b></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>得到结果</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><b><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>100/25   //</span></b></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>输入除法表达式，回车</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><b><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>4         //</span></b></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>得到结果</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><b><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>quit     //</span></b></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>退出指令</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>[root@192 ~]# </span></code></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>     2</span><span style='font-family:"Microsoft YaHei"'>）执行<span
lang=EN-US>for</span>循环语句</span></p>

<table class=a0 border=1 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse;border:none'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal style='line-height:200%'><code><b><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>for(i=0; i&lt;3;
  i++){print &quot;hello\n&quot;}   //</span></b></code><code><b><span
  style='font-size:10.0pt;line-height:200%;font-family:DengXian'>这是一个打印语句</span></b></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>hello</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>hello</span></code></p>
  <p class=MsoNormal style='line-height:200%'><code><span lang=EN-US
  style='font-size:10.0pt;line-height:200%;font-family:Menlo'>hello</span></code></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='text-indent:21.0pt;line-height:24.0pt'><span
lang=EN-US style='font-size:13.5pt;font-family:"Microsoft YaHei";color:black'>3</span><span
style='font-size:13.5pt;font-family:"Microsoft YaHei";color:black'>）从文件读取内容并且执行<span
lang=EN-US>bc</span></span></p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width="95%"
 style='width:95.0%;margin-left:24.1pt;border-collapse:collapse'>
 <tr style='height:14.9pt'>
  <td width=836 valign=top style='width:836.15pt;border:solid windowtext 1.0pt;
  background:#E7E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:14.9pt'>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>[root@localhost /]#&nbsp;<b>cat
  test.c
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</b></span><b><span
  style='font-size:10.0pt'>查看文件的内容，里面全是</span></b><b><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>bc</span></b><b><span
  style='font-size:10.0pt'>语句</span></b></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>/*define 3 functions add,sub,mul*/</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>define add(x,y){</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>&nbsp;&nbsp;&nbsp; return x+y;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>}</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>define sub(x,y){</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>&nbsp;&nbsp;&nbsp; return x-y;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>}</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>define mul(x,y){</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>&nbsp;&nbsp;&nbsp; return x*y;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>}</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>/*for statement*/</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>for(i=0;i&lt;3;i++){</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>&nbsp;&nbsp;&nbsp; print &quot;bc
  test &quot;,i,&quot;\n&quot;;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>}</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>/*print statement*/</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>print
  &quot;10+5=&quot;,add(10,5),&quot;\n&quot;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>print
  &quot;10-5=&quot;,sub(10,5),&quot;\n&quot;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>print &quot;10&amp;5=&quot;,mul(10,5),&quot;\n&quot;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>/*quit bc program*/</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>quit</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>[root@localhost /]#<b>&nbsp;bc
  test.c
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//bc</b></span><b><span
  style='font-size:10.0pt'>程序从文件获取到代码，然后执行</span></b></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>bc 1.06.95</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>Copyright 1991-1994, 1997, 1998,
  2000, 2004, 2006 Free Software Foundation, Inc.</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>This is free software with
  ABSOLUTELY NO WARRANTY.</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>For details type `warranty'.&nbsp;</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>bc test 0</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>bc test 1</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>bc test 2</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>10+5=15</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>10-5=5</span></p>
  <p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
  style='font-size:10.0pt;font-family:Menlo'>10&amp;5=50</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
style='font-size:13.5pt;font-family:"Microsoft YaHei";color:black'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:24.0pt'><span lang=EN-US
style='font-size:13.5pt;font-family:"Microsoft YaHei";color:black'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal style='line-height:200%'><span lang=EN-US style='font-family:
"Microsoft YaHei"'>&nbsp;</span></p>

<p class=MsoNormal align=center style='text-align:center;line-height:200%'><span
lang=EN-US style='font-family:"Microsoft YaHei"'>Copyright@david 
zhytwj2018@163.com</span></p>

</div>

</body>

</html>
